package com.wang.web3;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.wang.web3.bean.MarketGirlDetailBean;
import com.wang.web3.data.service.Business;
import com.wang.web3.data.service.ICallBackListener;

public class GirlsDetailActivity extends AppCompatActivity {


    private ImageView iv_girl;
    private Button btn_buy;
    private TextView tv_name, tv_owner;
    private int i;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.girl_detail);
        i = getIntent().getIntExtra("girlId", 0);
        initView();
        doGirlsDetailTask(i);
    }

    private void initView() {
        iv_girl = findViewById(R.id.iv_girl);
        btn_buy = findViewById(R.id.btn_buy);
        tv_name = findViewById(R.id.tv_name);
        tv_owner = findViewById(R.id.tv_owner);
    }

    public void doGirlsDetailTask(int girlId) {
        Business.getInstance().doGirlsDetailTask(girlId, new ICallBackListener() {
            @Override
            public void onSuccess(String mCallBackVo) {
                Gson mGson = new Gson();
                MarketGirlDetailBean girlDetailBean = mGson.fromJson(mCallBackVo, MarketGirlDetailBean.class);
                Log.i("zjf", girlDetailBean + "");
                Glide.with(getApplicationContext()).load(girlDetailBean.getData().getPicBody()).into(iv_girl);
                tv_name.setText("少女" + girlDetailBean.getData().getId());
                tv_owner.setText("qwe");
//                mGirlListArrayList.addAll(girlBean.getData());
//                mGirlAdapter.notifyDataSetChanged();
            }

            @Override
            public void onFaild(String mCallBackVo) {

            }
        });
    }
}
